<template>
  <div>
    <div>
      <el-table
        :data="tableData"
        border
        max-height="950"
        style="width: 100%">
        <el-table-column
          prop="playerNumber"
          label="在线人数">
        </el-table-column>
        <el-table-column
          prop="roomNumber"
          label="房间数量">
        </el-table-column>
        <el-table-column
          prop="recycle"
          label="当前回收">
        </el-table-column>
      </el-table>
    </div>
    <el-divider content-position="center">服务器操作</el-divider>
    <div>
      <el-table :data="itemDate" border stripe  style="width: 100%;">
        <el-table-column
          prop="operation"
          label="服务器操作"
          width="180"
          align="center">

        </el-table-column>
        <el-table-column
          prop="operationType"
          label="类型"
          width="210"
          align="center">
        </el-table-column>
        <el-table-column prop="click" label="操作" width="210" align="center">
          <template slot-scope="scope">
            <div style="margin-top: 3px">
              <el-button type="success" plain @click="onSubmit(scope.row)">提交</el-button>
            </div>
            <span></span>
          </template>
        </el-table-column>
      </el-table>
    </div>
  </div>
</template>
<script>
  import axios from 'axios'
  export default {
    created(){
      axios.get("/niuscene").then(resp => {
        if(resp.data.result){
          this.tableData = [resp.data.msg]
        }
      })
    },
    data() {
      return {
        itemDate: [{
          operation: '服务器操作',
          operationType: '暂停服务',
        },{
          operation: '服务器操作',
          operationType: '更新数据',
        }],
        tableData: [{
          playerNumber: '0',
          roomNumber: '0',
          recycle: '0',
        }],
      }
    },
    methods: {
      onSubmit(row){
        var urlTemp = 'niuupdateexcel';
        if(row.operationType === "暂停服务"){
          urlTemp = 'niustopservice';
          console.log(urlTemp);
        }else if(row.operationType === "更新数据"){
          urlTemp = 'niuupdateexcel';
          console.log(urlTemp);
        }
        axios.get(urlTemp).then(resp => {
          if(resp.data.result){
            this.$notify({
              title: '成功',
              message: resp.data.msg,
              type: 'success'
            });
          }else {
            this.$message({
              showClose: true,
              message: resp.data.error,
              type: 'error'
            });
          }
        }).catch(error => {
          this.$message({
            showClose: true,
            message: error,
            type: 'error'
          });
        });
      }
    }
  }
</script>

<style scoped>

</style>

